package jblip.gui.data.channels;

import jblip.gui.JBlip;
import jblip.resources.Update;
import jblip.util.UpdatesFilter.UpdateNumberFilter;

public class UserDataChannel extends UpdatesDataChannel {

  private final String user;

  UserDataChannel(final String username) {
    super(String.format("^%s", username));
    user = username;
  }

  @Override
  protected Iterable<? extends Update> getUpdates() {
    return JBlip.instance().getBlipClient().pollDashboard(
        user, null, null, null);
  }

  @Override
  protected Iterable<? extends Update> getUpdates(int last_update_id) {
    UpdateNumberFilter filter = new UpdateNumberFilter(last_update_id);
    
    return filter.filter(JBlip.instance().getBlipClient().pollDashboard(
        user, last_update_id, null, null));
  }

  public String getUserName() {
    return user;
  }

}
